﻿using CJAtech.BBS.Process;
using CJAtech.BBS.Web.Filters;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Bigger.Framework;

namespace CJAtech.BBS.Web.Controllers
{
    public partial class BBSController
    {
        public ActionResult ArticlesTemplate()
        {
            string viewName = this.CheckViewExist();
            return View(viewName);
        }

        public ActionResult ArticleTemplate(int? id)
        {
            if (!id.HasValue)
            {
                return Http404();
            }
            string viewName = this.CheckViewExist();
            ArticleInfoProcess objArticleInfoProcess = new ArticleInfoProcess(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
            ArticleResultInfo objArticleResultInfo = objArticleInfoProcess.GetArticleResultInfo(id.Value, false, false);
            if (objArticleResultInfo == null || objArticleResultInfo.ArticleInfo == null)
            {
                return Http404();
            }
            if (objArticleResultInfo.ArticleInfo.IsRelease != 1 && !string.Equals(objArticleResultInfo.ArticleInfo.ObjectId, this.CurrentUserInfo.UserId))
            {
                return Content("对不起，当前文章还在审核中");
            }
            //更新文章的浏览数
            objArticleInfoProcess.IncreaseViewCount(id.Value);
            return View(viewName);
        }

        [SSOAuthorFilter(PowerType.None)]
        public ActionResult StaticTemplate()
        {
            string viewName = this.CheckViewExist();
            return View(viewName);
        }

        public ActionResult StaticPowerTemplate()
        {
            string viewName = this.CheckViewExist();
            return View(viewName);
        }
    }
}
